home *** CD-ROM | disk | FTP | other *** search
- /*
- * Hand-coded routines for C TeX.
- * This module should contain any system-dependent code.
- *
- * This code was written by Tim Morgan, drawing from other Unix
- * ports of TeX.
- * hacked up for MEGAMAX-C on ATARI ST by David Dermott
- */
-
- /*#define CATCHINT*/ /* Catch ^C's */
- /*#undef SYSV */ /* Turn on System V compatibility */
- /*#define BSD */ /* 4.[23]BSD */
-
- #define EXTERN /* Actually instantiate globals here */
-
- #include "texd.h"
- #include <osbind.h> /* st os routines */
- #ifdef CATCHINT
- #include <signal.h>
- #endif
- #ifdef BSD
- #include <sys/time.h>
- #else
- #include <time.h>
- #endif
- /*#if defined(BSD)||defined(SYSV)
- #include <sgtty.h>
- #endif
- */
-
- #ifdef VMS
- #define index strchr /* Sys V compatibility */
- #endif
-
- /* C library stuff that we're going to use */
- extern char *strcpy(), *strcat(), *malloc(), *sprintf(), *index(), *getenv();
-
- /* Local stuff */
- static int gargc;
- static char **gargv;
- static char texformats[filenamesize], texinputs[filenamesize];
- static char texfonts[filenamesize], texpool[filenamesize];
- static char my_realnameoffile[filenamesize];
- /*static char *texeditvalue = "/usr/ucb/vi +%d %s";*/
- static char *texeditvalue = "EMACS.TTP -g%d %s";
-
- #define TRUE 1
- #define FALSE 0
-
- #ifdef CATCHINT
- /* If we're catching ^C, come here when one comes in. */
- static catchint()
- {
- interrupt = 1;
- (void) signal(SIGINT, catchint);
- }
- #endif
-
- /* Do the obvious */
- get_date_and_time(minutes, day, month, year)
- integer *minutes, *day, *month, *year;
- {
- long clock, time();
- struct tm *tmptr, *localtime();
-
- clock = time((long *) 0);
- tmptr = localtime(&clock);
-
- *minutes = tmptr->tm_hour * 60 + tmptr->tm_min;
- *day = tmptr->tm_mday;
- *month = tmptr->tm_mon + 1;
- *year = tmptr->tm_year + 1900;
- #ifdef CATCHINT
- (void) signal(SIGINT, catchint);
- #endif
-
- }
-
- #ifdef INITEX
- /* Read until we pass end of line on the input file, a la Pascal */
- readln(f)
- FILE *f;
- {
- register int c;
-
- do
- c = getc(f);
- while (c != '\n' && c != EOF);
- }
-
- /* Same as in Pascal --- return TRUE if EOF or next char is newline */
- eoln(f)
- FILE *f;
- {
- register int c;
-
- if (feof(f)) return(TRUE);
- c = getc(f);
- if (c != EOF)
- (void) ungetc(c, f);
- return (c == '\n' || c == EOF);
- }
- #endif /* INITEX */
-
- static void copy_path(ptr, defptr, override)
- char *ptr, *defptr, *override;
- {
- if (override) {
- if (strlen(override) >= 1024) {
- (void) fprintf(stderr, "Path too long\n");
- exit(1);
- }
- (void) strcpy(ptr, override);
- }
- else
- (void) strcpy(ptr, defptr);
- }
-
-
- /* Initialize path variables for loading fonts and things */
- setpaths()
- {
- copy_path(texformats, TEXFORMATS, getenv("TEXFORMATS"));
- copy_path(texinputs, TEXINPUTS, getenv("TEXINPUTS"));
- copy_path(texfonts, TEXFONTS, getenv("TEXFONTS"));
- copy_path(texpool, TEXPOOL, getenv("TEXPOOL"));
- }
-
- /*
- * The following procedure is due to sjc@s1-c.
- *
- * calledit(filename, fnstart, fnlength, linenumber)
- *
- * TeX82 can call this to implement the 'e' feature in error-recovery
- * mode, invoking a text editor on the erroneous source file.
- *
- * You should pass to "filename" the first character of the packed array
- * containing the filename, and to "fnstart" and "fnlength" the index and
- * length of the filename as it appears inside that array.
- *
- * Ordinarily, this invokes "/usr/ucb/vi". If you want a different
- * editor, create a shell environment variable TEXEDIT containing
- * the string that invokes that editor, with "%s" indicating where
- * the filename goes and "%d" indicating where the decimal
- * linenumber (if any) goes. For example, a TEXEDIT string for a
- * variant copy of "vi" might be:
- *
- * setenv TEXEDIT "/usr/local/bin/vi +%d %s"
- *
- */
-
- calledit(filename, fnstart, fnlength, linenumber)
- ASCIIcode filename[];
- poolpointer fnstart;
- integer fnlength, linenumber;
- {
- char *temp, *command, c;
- int sdone, ddone, i;
- /* close all input files */
- for (i=1;i<= inopen;i++)fclose(inputfile[i]);
- /* so they can be editted */
- freemem();/* free some memory*/
- sdone = ddone = 0;
- filename += fnstart;
-
- /* Replace default with environment variable if possible. */
- if (NULL != (temp = getenv("TEXEDIT")))
- texeditvalue = temp;
-
- /* Make command string containing envvalue, filename, and linenumber */
- if (NULL ==
- (command = (char *) malloc((unsigned) strlen(texeditvalue) + (int)fnlength
- + 25))) {
- (void) fprintf(stderr, "! Not enough memory to issue editor command\n");
- exit(1);
- }
- temp = command;
- while ((c = *texeditvalue++) != '\0') {
- if (c == '%') {
- switch (c = *texeditvalue++) {
- case 'd':
- if (ddone) {
- (void) fprintf(stderr,
- "! Line number cannot appear twice in editor command\n");
- exit(1);
- }
- (void) sprintf(temp, "%d", (int)linenumber);
- while (*temp != '\0')
- temp++;
- ddone = 1;
- break;
- case 's':
- if (sdone) {
- (void) fprintf(stderr,
- "! Filename cannot appear twice in editor command\n");
- exit(1);
- }
- i = 0;
- while (i < fnlength)
- *temp++ = filename[i++];
- sdone = 1;
- break;
- case '\0':
- *temp++ = '%';
- texeditvalue--; /* Back up to \0 to force termination. */
- break;
- default:
- *temp++ = '%';
- *temp++ = c;
- break;
- }
- }
- else
- *temp++ = c;
- }
- *temp = '\0';
- /* Execute command. */
- if (system(command))
- (void) fprintf(stderr, "! Trouble executing command %s\n", command);
-
- /* Quit, indicating TeX found an error */
- exit(1);
- }
-
-
- /*
- * Change a Pascal-like filename into a C-like string.
- * If running on a non-ASCII system, will have to use xchr[]
- * array to convert from internal character set (in the "nameoffile"
- * array) into the enternal character set (in "realnameoffile").
- * "nameoffile" is an array indexed starting with 1, so we add 1
- * to all references to point to the first character in the name.
- */
- static packrealnameoffile(prefix)
- char *prefix;
- {
- register char *cp, *p, *q;
-
- p = prefix;
- for (q = my_realnameoffile; p && *p && *p != ';'; *q++ = *p++);
- if (prefix && *prefix)
- *q++ = '\\';
- for (cp = nameoffile+1, p = realnameoffi + 1; *cp != ' ' && *cp;)
- #ifdef NONASCII
- *q++ = xchr[*p++ = *cp++];
- #else
- *q++ = (*p++ = *cp++);
- #endif
- *p = ' ';
- *q = '\0';
- }
-
- /* Open an input file f */
- Openin(f, pathspec,fmode)
- FILE **f;
- int pathspec;
- char fmode[];
- {
- register char *prefix, *nprefix;
- register char *cp;
- /*printf("name %s mode %s path %d ",&nameoffile[1],fmode,pathspec);*/
- switch (pathspec) {
- case inputpathspec:
- case readpathspec:
- prefix = texinputs;
- break;
- case fontpathspec:
- prefix = texfonts;
- break;
- case poolpathspec:
- prefix = texpool;
- break;
- case fmtpathspec:
- prefix = texformats;
- break;
- default: /* "Can't" happen */
- (void) fprintf(stderr, "INTERNAL CONFUSION---IMPLEMENTATION ERROR\n");
- exit(1);
- }
- /*printf(" %s \n",prefix);*/
- if ((nameoffile[2] == ':')||(nameoffile[1] == '/')) {/* Absolute pathname */
- for (cp = nameoffile+1; *cp && *cp != ' '; ++cp);
- *cp = '\0';
- /*printf("absolute %s\n",nameoffile);*/
- cnvtfn(nameoffile+1);
- if (*f = fopen(nameoffile+1, fmode)) {
- (void) strcpy(realnameoffi + 1, nameoffile+1);
- (void) strcat(realnameoffi + 1, " ");
- if (pathspec == fontpathspec)
- tfmtemp = getc(*f); /* Simulate readahead */
- return (1);
- }
- return (0);
- }
- /* Else relative pathname */
- while (prefix) {
- packrealnameoffile(prefix);
- /*printf("try %s %s\n",my_realnameoffile,prefix);*/
- cnvtfn(my_realnameoffile);
- *f = fopen(my_realnameoffile, fmode);
- if (*f) {
- (void) strcpy(realnameoffi + 1, my_realnameoffile);
- (void) strcat(realnameoffi + 1, " ");
- if (pathspec == fontpathspec)
- tfmtemp = getc(*f); /* Simulate Pascal readahead */
- return (1);
- }
- nprefix = index(prefix, ';');
- if (nprefix)
- prefix = nprefix + 1;
- else
- break;
- }
- return (0);
- }
- /* translate / to \ in file name */
- cnvtfn(p)
- char *p;
- {
- while(*p != 0){
- if(*p == '/')*p = '\\';
- p++;
- }
- }
-
-
- /* Open an output file f */
- Openout(f,fmode)
- FILE **f;
- char fmode[];
- {
- /*printf("open write %s mode %s\n",&nameoffile[1],fmode);*/
- packrealnameoffile((char *) NULL);
- /*printf("packed name %s\n",my_realnameoffile);*/
- *f = fopen(my_realnameoffile, fmode);
- return (*f != NULL);
- }
-
-
- /*
- * Read a line of input as efficiently as possible while still
- * looking like Pascal.
- * Sets last==first and returns FALSE if eof is hit.
- * Otherwise, TRUE is returned and either last==first or buffer[last-1]!=' ';
- * that is, last == first + length(line except trailing whitespace).
- */
- boolean zinputln(f)
- FILE *f;
- {
- register int i;
-
-
- last = first;
- while ( last < bufsize && ((i = getc(f)) != EOF) && i != '\n') {
- buffer[last++] = i;
- }
- if (i == EOF && last == first)
- return(FALSE);
- if (i != EOF && i != '\n') {
- /* We didn't get whole line because of lack of buffer space */
- (void) fprintf(stderr, "\nUnable to read an entire line---bufsize=%d\n",
- bufsize);
- exit(1);
- }
- buffer[last] = ' ';
- if (last >= maxbufstack)
- maxbufstack = last; /* Record keeping */
- /* Trim trailing whitespace by decrementing "last" */
- while (last > first && (buffer[last-1] == ' ' || buffer[last-1] == '\t'))
- --last;
- /* Now, either last==first or buffer[last-1] != ' ' (or tab) */
- /*
- * If we're running on a system with ASCII characters like TeX's
- * internal character set, we can save some time by not executing
- * this loop.
- */
- #ifdef NOTASCII
- for (i = first; i <= last; i++)
- buffer[i] = xord[buffer[i]];
- #endif
- /*printf("line done last= %ld\n",last);*/
- return(TRUE);
- }
-
- /*
- * Clear any pending terminal input.
- * The usual way to do this in Unix is to switch the terminal to get
- * the current tty flags, set RAW mode, then switch back to the original
- * setting. If the user isn't in COOKED mode, though, this won't work.
- * At least, it leaves his terminal in its original mode.
- */
- cleartermina()
- {
- #ifdef BSD
- struct sgttyb sb;
- int flags; /* We save the original flags here */
-
- if (ioctl(fileno(stdout), TIOCGETP, &sb) < 0)
- return; /* Failed for some reason */
- flags = sb.sg_flags;
-
- sb.sg_flags |= RAW;
- if (ioctl(fileno(stdout), TIOCSETP, &sb) < 0)
- return; /* Punt if it fails */
-
- sb.sg_flags = flags;
- (void) ioctl(fileno(stdout), TIOCSETP, &sb);
- #endif /* BSD */
- }
-
-
- /*
- * Cancel any output cancellation (^O) by the user. This is 4.2BSD code.
- * Systems which don't have this feature might want to #define wakeupterminal
- * to do nothing, rather than call this empty routine, but it's only called
- * when about to read from the terminal, so the extra time (compared with
- * the human's response time) is minimal.
- */
- wakeuptermin()
- {
- #ifdef BSD
- int i = LFLUSHO;
-
- (void) ioctl(fileno(stdout), TIOCLBIC, (struct sgttyb *) &i);
- #endif /* BSD */
- }
-
-
- /*
- * "Open the terminal for input". Actually, copy any command-line
- * arguments for processing. If nothing is available, or we've
- * been called already (and hence, gargc==0), we return with last==first.
- */
- topenin()
- {
- register int i;
-
- if (gargc > 1) {
- buffer[first] = '\0'; /* This makes the first strcat work */
- for (i=1; i<gargc; i++) {
- (void) strcat((char *) &buffer[first], gargv[i]);
- (void) strcat((char *) &buffer[first], " ");
- }
- gargc = 0; /* Don't do this again */
- for (last=first; buffer[last]; ++last);
- for (--last; last >= first && buffer[last] == ' '; --last);
- ++last;
- }
- else last = first; /* This signals that nothing is available */
- }
-
-
- #ifdef sequent
- /*
- * On a Sequent Balance system under Dynix 2.1, if u and v are unsigned
- * quantities, then "(int) u - (int) v" does not perform a signed
- * subtraction. Hence we have to call this routine to force the compiler
- * to treat u and v as ints instead of unsigned ints.
- */
- int ztoint(x)
- {
- return(x);
- }
- #endif
- putlw(lword,fpp)
- long lword;
- FILE *fpp;
- {
- fwrite(&lword,4,1,fpp);
- }
- fmtwrite(bb,l1,l2,fpp)
- char *bb;
- int l1;
- long l2;
- FILE *fpp;
- {
- register long l1l2,i;
- l1l2=l1*l2;
- /*fflush(fpp);
- Fwrite(fileno(fpp),l1l2,bb);*/
- for (i=0;i<l1l2;i++)putc(bb[i],fpp);
- }
-
- fmtread(bb,l1,l2,fpp)
- char *bb;
- int l1;
- long l2;
- FILE *fpp;
- {
- register long l1l2,i;
- l1l2=l1*l2;
- /*fflush(fpp);
- Fread(fileno(fpp),l1l2,bb);*/
- for (i=0;i<l1l2;i++)bb[i]=getc(fpp);
- }
-
- /* special dvi write for VMS */
- /* always write 512 bytes */
- dwrite(bb,l1,l2,fpp)
- char bb[];
- int l1,l2;
- FILE *fpp;
- {
- int i,k;
- int l1l2;
- l1l2=l1*l2;
- k=512;
- if(l1l2 > 512)k=1024;
- /*printf("l1,l2 %d %d %d %d\n",l1,l2,l1l2,k);*/
- if(l1l2 <= 0)return;
- if(l1l2 < k){
- for(i=l1l2;i<k;i++)bb[i]=0xDF;
- }
- write(fileno(fpp),bb,k);
- }
-
-
- /*
- * Get things going under Unix: set up for rescanning the command line,
- * then call TeX's main body.
- */
- main(argc, argv)
- int argc;
- char *argv[];
- {
- gargc=argc;
- gargv=argv;
- memtop=MEMTOP;
- memmax=MEMMAX;
- memall(); /* allocate memory */
- printf(" memory free %ld\n",(long)Malloc(-1L));
-
- /*printf("zmem,zeqt %lx %lx \n",(long)zzzaa,(long)zeqtb);*/
- #include "arrays.h"
- texbody();
- }
-
-
- #ifdef DEBUG
- getint()
- {
- int i;
-
- if (fscanf(stdin, "%d", &i)) return(i);
- return(0);
- }
- #endif /* DEBUG */
- /* getenv wasn't in MEGAMAX library */
- /* also time() and localtime() and time.h had to be written */
- extern long *_base;
- char *getenv(stpath)
- char stpath[];
- {
- char *ptr;
- int i;
- ptr= (char *)*(_base+11);
- i=strlen(stpath);
- while(*ptr != 0){
- if((strncmp(stpath,ptr,i)== 0)&&(ptr[i] == '='))return(ptr+i+1);
- ptr=ptr+strlen(ptr)+1;
- }
- return(NULL);
- }
- /* simple time functions NOT UNIX compatible but they
- suit some purposes */
-
-
- long time(ttime)
- long *ttime;
- {
- int ttvec[2];
- long daytime;
- daytime=Gettime();
- ttvec[0]=(daytime & 0xffff);
- ttvec[1]=(daytime>>16) & 0xffff;
- Tsettime(ttvec[0]);
- Tsetdate(ttvec[1]);
- if((ttime != NULL) )*ttime=daytime;
- return(daytime);
- }
-
- struct tm *localtime(daytime)
- long *daytime;
- {
- int ttvec[2];
- static struct tm tt;
- ttvec[0]=(*daytime & 0xffff);
- ttvec[1]=(*daytime>>16) & 0xffff;
- tt.tm_sec= (ttvec[0]&31)*2;
- tt.tm_min= (ttvec[0]>>5)&63;
- tt.tm_hour= (ttvec[0]>>11)&31;
- tt.tm_mday= (ttvec[1]&31);
- tt.tm_mon= ((ttvec[1]>>5)&15)-1;
- tt.tm_year= ((ttvec[1]>>9)&127)+80;
- tt.tm_isdst= 0;
- return (&tt);
- }
-
-
-
-
- extern char *palloc();
- memall()
- {
- /* ASCIIcode strpool[poolsize + 1] ; */
- strpool = (ASCIIcode *)palloc( (long)poolsize + 1,sizeof(ASCIIcode ) );
- /* poolpointer strstart[maxstrings + 1] ; */
- strstart = (poolpointer *)palloc( (long)maxstrings + 1,sizeof(poolpointer ) );
- /* memoryword zzzaa[memmax - memmin + 1] ; */
- zzzaa = (memoryword *)palloc( (long)memmax - memmin + 1,sizeof(memoryword ) );
- #ifdef DEBUG
- /* boolean zzzab[memmax - memmin + 1], *freearr ; */
- zzzab = (boolean *)palloc( (long)memmax - memmin + 1,sizeof(boolean ) );
- /* boolean zzzac[memmax - memmin + 1], *wasfree ; */
- zzzac = (boolean *)palloc( (long)memmax - memmin + 1,sizeof(boolean ) );
- #endif /* DEBUG*/
- /* memoryword zeqtb[5977] ; */
- zeqtb = (memoryword *)palloc( (long)5977,sizeof(memoryword ) );
- /* quarterword zzzad[710], *xeqlevel ; */
- zzzad = (quarterword *)palloc( (long)710,sizeof(quarterword ) );
- /* twohalves zzzae[3267], *hash ; */
- zzzae = (twohalves *)palloc( (long)3267,sizeof(twohalves ) );
- /* memoryword savestack[savesize + 1] ; */
- savestack = (memoryword *)palloc( (long)savesize + 1,sizeof(memoryword ) );
- /* instaterecor inputstack[stacksize + 1] ; */
- inputstack =(instaterecor *)palloc( (long)stacksize + 1,sizeof(instaterecor) );
- /* memoryword fontinfo[fontmemsize + 1] ; */
- fontinfo = (memoryword *)palloc( (long)fontmemsize + 1,sizeof(memoryword ) );
- /* fourquarters fontcheck[fontmax + 1] ; */
- fontcheck = (fourquarters *)palloc( (long)fontmax + 1,sizeof(fourquarters ) );
- /* scaled fontsize[fontmax + 1] ; */
- fontsize = (scaled *)palloc( (long)fontmax + 1,sizeof(scaled ) );
- /* scaled fontdsize[fontmax + 1] ; */
- fontdsize = (scaled *)palloc( (long)fontmax + 1,sizeof(scaled ) );
- /* halfword fontparams[fontmax + 1] ; */
- fontparams = (halfword *)palloc( (long)fontmax + 1,sizeof(halfword ) );
- /* strnumber fontname[fontmax + 1] ; */
- fontname = (strnumber *)palloc( (long)fontmax + 1,sizeof(strnumber ) );
- /* strnumber fontarea[fontmax + 1] ; */
- fontarea = (strnumber *)palloc( (long)fontmax + 1,sizeof(strnumber ) );
- /* eightbits fontbc[fontmax + 1] ; */
- fontbc = (eightbits *)palloc( (long)fontmax + 1,sizeof(eightbits ) );
- /* eightbits fontec[fontmax + 1] ; */
- fontec = (eightbits *)palloc( (long)fontmax + 1,sizeof(eightbits ) );
- /* halfword fontglue[fontmax + 1] ; */
- fontglue = (halfword *)palloc( (long)fontmax + 1,sizeof(halfword ) );
- /* boolean fontused[fontmax + 1] ; */
- fontused = (boolean *)palloc( (long)fontmax + 1,sizeof(boolean ) );
- /* integer hyphenchar[fontmax + 1] ; */
- hyphenchar = (integer *)palloc( (long)fontmax + 1,sizeof(integer ) );
- /* integer skewchar[fontmax + 1] ; */
- skewchar = (integer *)palloc( (long)fontmax + 1,sizeof(integer ) );
- /* integer charbase[fontmax + 1] ; */
- charbase = (integer *)palloc( (long)fontmax + 1,sizeof(integer ) );
- /* integer widthbase[fontmax + 1] ; */
- widthbase = (integer *)palloc( (long)fontmax + 1,sizeof(integer ) );
- /* integer heightbase[fontmax + 1] ; */
- heightbase = (integer *)palloc( (long)fontmax + 1,sizeof(integer ) );
- /* integer depthbase[fontmax + 1] ; */
- depthbase = (integer *)palloc( (long)fontmax + 1,sizeof(integer ) );
- /* integer italicbase[fontmax + 1] ; */
- italicbase = (integer *)palloc( (long)fontmax + 1,sizeof(integer ) );
- /* integer ligkernbase[fontmax + 1] ; */
- ligkernbase = (integer *)palloc( (long)fontmax + 1,sizeof(integer ) );
- /* integer kernbase[fontmax + 1] ; */
- kernbase = (integer *)palloc( (long)fontmax + 1,sizeof(integer ) );
- /* integer extenbase[fontmax + 1] ; */
- extenbase = (integer *)palloc( (long)fontmax + 1,sizeof(integer ) );
- /* integer parambase[fontmax + 1] ; */
- parambase = (integer *)palloc( (long)fontmax + 1,sizeof(integer ) );
- /* twohalves trie[triesize + 1] ; */
- trie = (twohalves *)palloc( (long)triesize + 1,sizeof(twohalves ) );
- #ifdef INITEX
- /* ASCIIcode triec[triesize + 1] ; */
- triec = (ASCIIcode *)palloc( (long)triesize + 1,sizeof(ASCIIcode ) );
- /* quarterword trieo[triesize + 1] ; */
- trieo = (quarterword *)palloc( (long)triesize + 1,sizeof(quarterword ) );
- /* triepointer triel[triesize + 1] ; */
- triel = (triepointer *)palloc( (long)triesize + 1,sizeof(triepointer ) );
- /* triepointer trier[triesize + 1] ; */
- trier = (triepointer *)palloc( (long)triesize + 1,sizeof(triepointer ) );
- /* triepointer triehash[triesize + 1] ; */
- triehash = (triepointer *)palloc( (long)triesize + 1,sizeof(triepointer ) );
- /* boolean trietaken[triesize + 1] ; */
- trietaken = (boolean *)palloc( (long)triesize + 1,sizeof(boolean ) );
- #endif /* INITEX */
-
- }
- /* allocate memory */
- char *palloc(nelem,sizel)
- long nelem;
- int sizel;
- {
- register char *pp;
- /* printf(" allocating %ld\n",nelem*sizel);*/
- if(pp =(char *)Malloc(nelem*sizel)) {
- /* printf(" memory free %ld\n",(long)Malloc(-1L));*/
- return(pp);}
- else {
- printf("can't allocate \n");
- exit(1);}
- }
- freemem() /* free memory */
- {
- #ifdef INITEX
- Mfree(trietaken);
- Mfree(triehash);
- Mfree(trier);
- Mfree(triel);
- Mfree(trieo);
- Mfree(triec);
- #endif /* INITEX */
- Mfree(trie);
- Mfree(parambase);
- Mfree(extenbase);
- Mfree(kernbase);
- Mfree(ligkernbase);
- Mfree(italicbase);
- Mfree(depthbase);
- Mfree(heightbase);
- Mfree(widthbase);
- Mfree(charbase);
- Mfree(skewchar);
- Mfree(hyphenchar);
- Mfree(fontused);
- Mfree(fontglue);
- Mfree(fontec);
- Mfree(fontbc);
- Mfree(fontarea);
- Mfree(fontname);
- Mfree(fontparams);
- Mfree(fontdsize);
- Mfree(fontsize);
- Mfree(fontcheck);
- Mfree(fontinfo);
- Mfree(inputstack);
- Mfree(savestack);
- Mfree(zzzae);
- Mfree(zzzad);
- Mfree(zeqtb);
- #ifdef DEBUG
- Mfree(zzzac);
- Mfree(zzzab);
- #endif */DEBUG */
- Mfree(zzzaa);
- Mfree(strstart);
- Mfree(strpool);
- printf(" memory free %ld\n",(long)Malloc(-1L));
-
- }
-
-
- /* homebrew system function */
- system(command)
- char *command;
- {char pname[20];
- char fpname[40];
- char comtail[40];
- char *ptr;
- int l;
- for(l=0;l<strlen(command);l++){
- if(command[l] == ' ')break;
- pname[l]=command[l];
- }
- pname[l]=0;
- if(command[l]== ' '){ strcpy(&comtail[1],&command[l+1]);
- comtail[0]=strlen(&comtail[1]);
- }
- else {comtail[0]=0;comtail[1]=0;}
- if(find_file(pname,fpname) == 0)return (-1);
- return(Pexec(0x00, fpname, comtail, NULL)); /* load and execute */
-
- }
- /* find a file using PATH environment */
- find_file(temptr,fullnam)
- char *temptr,*fullnam;
- {
- char *ptrz,*ptry;
-
- int ch;
- int fflag;
-
- fflag=0;
- ptrz=getenv("PATH");
- strcpy(fullnam,temptr);
- if((index(fullnam,':')!= NULL) || (index(fullnam,'\\')!= NULL))fflag=1;
- while(1){
-
-
- if ((ch = Fopen(fullnam, 0)) >= 0)
- {
- Fclose(ch);
- return(1);
- }
- if((fflag == 1)||(*ptrz == 0))break;
- ptry=fullnam;
- while((*ptrz != ';')&&(*ptrz != 0)){
- *ptry = *ptrz;
- ptry++;
- ptrz++;
- }
- if(*(ptry-1) != '\\')*ptry++ = '\\';
- strcpy(ptry,temptr);
- if(*ptrz == ';')ptrz++;
- }
- return(0);
- }
-
-